#coding=utf-8
from django.db import models
from item.models import *

# Create your models here.

class Comment(models.Model):
    index          = models.IntegerField('评论位置')
    title          = models.CharField('评论标题', max_length = 128)
    author         = models.CharField('作者', max_length = 20, blank = True)
    rank           = models.IntegerField('评分')
    status         = models.CharField('状态', max_length = 32)
    publishDate    = models.DateTimeField('发布时间', auto_now_add = True)
    updateDate     = models.DateTimeField('更新时间', auto_now = True)
    referTo        = models.ForeignKey(Item, verbose_name = '评论于')
    replyTo        = models.ForeignKey('self', verbose_name = '回复', null = True, blank = True)
    content        = models.TextField('评论内容')
    allowRead      = models.BooleanField('是否加密')
	
    class Meta:
        get_latest_by           = "publishDate"
        verbose_name_plural 	= '评论'

    def get_absolute_url(self):
        return "/c/%i/" % self.id

    def __unicode__(self):
        return '%s' % (self.title)	
    